<template>
	<view>
		<view class="topview">
			<u-search searchIconSize="35" bgColor='#fff' searchIconColor='#1590EF' borderColor='#B5B9CD'
			@search="searchClick()" @custom="searchClick()"  v-model="searchText"	:showAction="true" placeholder="请输入车牌号码" actionText="搜索" :animation="true">
			</u-search>
		</view>


		<!-- 企业信息 -->
		<view style="padding-bottom: 20rpx;">
			<view class="viewpage">
				<text>{{ownerName}}</text>
				<v-table :columns="columns" :list="data"></v-table>
			</view>

		</view>





	</view>
</template>


<script>
	import {
		jyxkzYq
	} from '@/common/api/req.js'
	import vTable from '../warning/components/table.vue'
	export default {
		components: {
			vTable
		},
		data() {
			return {
				searchText:"",
				data: [
				// 	{
				// 	carNo: 'John Brown',
				// 	time: '未按照实际作业时间操作',
				// 	id: "1",
				// }, 
				],
				columns: [{
						title: "序号",
						key: "id",
						$width: '40px',

					},
					{
						title: '车牌号码（颜色）',
						key: 'carNo',
						$width: '160px'
					},

					{
						title: '道路运输证有效期至',
						key: 'time',
						$width: '170px'
					}
				],
				ownerName: '',
				objData: {},
				current: 1,
				size: 10,
				isloading:false,

			};
		},
		onLoad(option) {

			this.objData = JSON.parse(option.item)
			console.log(this.objData, '-----')
			// console.log(ownername, '000000000000');
			this.ownerName = this.objData.inspObjName

			// uni.setNavigationBarTitle({
			// 	title:inspObjName 
			// });
		},
		mounted() {
			this.getData("","")
		},

		methods: {
			searchClick(){
				if(this.searchText==''){
					uni.showToast({
						title:'请输入车辆号码',
						icon:'none'
					})
				}else{
				   this.getData(this.searchText,"")
				}
			},
			tabClick() {},
			getData(carNo,personName) {
				this.isloading = true
				jyxkzYq({
					current: this.current,
					size: 9999,
					ownerId: this.objData.inspObjId, //企业id（从列表获取原样传回来）
					warningCategory: this.objData.warningCategory, //预警分类（从列表获取原样传回来）
					warningType: this.objData.warningType, //预警类型（从列表获取原样传回来）
					warningInfo: this.objData.warningInfo, //预警信息（从列表获取原样传回来）
					carNo: carNo, //车牌号
					personName: personName, //人员名称
					matchType: "" //1/2/3；有运单无轨迹/无运单有轨迹/运单轨迹不符车辆数（预警类型为：电子运单检测异常时需要传该值）
				}).then(res => {
					let data = res.data.data.records
					this.isloading = false
					if(data.length>0){
						data.forEach((item,index)=>{
							item.id=index+1
							item.carNo=item.carNo+" ("+item.carColor+")"
						})
						this.data=data
					}else{
						uni.showToast({
							title:'暂无数据',
							icon:'none'
						})
					}
				})
			},
			onReachBottom() {
				if (this.isloading) return
				this.current += 1
				this.getData("","")
			},
			itemClick(item) {
				this.$goBack('../msgQuery/integral_rule', 2);
			}

		}
	}
</script>

<style lang="scss">
	page {
		background-color: #F7FBFC;
	}

	.topview {
		padding: 10px 15px;
		background-color: #F7FBFC;
		position: sticky;
		z-index: 999;
		top: 0;


		.u-search__content {
			padding: 5px 10px;
		}
	}

	.viewpage {
		// padding: 20rpx;
		text-align: center;
		background-color: #ffffff;
		width: 370px;
		margin: 0 auto;
		// margin-top: 10px;
		padding-top: 20rpx;
		padding-bottom: 20rpx;
		border-radius: 10rpx;
		border: 2rpx #B5B9CD solid;

		text {
			font-size: 34rpx;
		}
	}
</style>
